<div class="layuimini-container layuimini-page-anim">
  <div class="layuimini-main">

    <fieldset class="table-search-fieldset">
      <legend>搜索信息</legend>
      <div style="margin: 10px 10px 10px 10px">
        <!--        <form class="layui-form layui-form-pane" action="">-->
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-inline">
              <input type="text" id="username" name="username" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-inline">
            <button class="layui-btn layui-btn-primary" id="btn" lay-filter="data-search-btn">
              <i class="layui-icon"></i> 搜 索
            </button>
          </div>
        </div>
        <!--        </form>-->
      </div>
    </fieldset>

    <script type="text/html" id="toolbarDemo">
      <div class="layui-btn-container">
        <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加</button>
        <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除</button>
      </div>
    </script>

    <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

    <script type="text/html" id="currentTableBar">
      <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
      <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
    </script>

  </div>
</div>

<script>
  layui.use(['form', 'table', 'miniPage', 'element'], function(){
    var $ = layui.jquery, form = layui.form, table = layui.table, miniPage = layui.miniPage;

    table.render({
      elem: '#currentTableId',
      code: 0,
      msg: "",
      count: 1,
      data: [
        {
          "id": window.localStorage.getItem('username')[1],
          "username": window.localStorage.getItem('username'),
          "password": window.localStorage.getItem('username')
        }
      ],
      toolbar: '#toolbarDemo',
      defaultToolbar: ['filter', 'exports', 'print', {
        title: '提示', layEvent: 'LAYTABLE_TIPS', icon: 'layui-icon-tips'
      }],
      cols: [[{field: 'id', width: 250, title: 'ID', sort: true}, {field: 'username', width: 525, title: '用户名'},
        {field: 'password', width: 525, title: '密码'},]],
      limits: [10, 15, 20, 25, 50, 100],
      limit: 15,
      page: true,
      skin: 'line'
    });

    // 监听搜索操作
    let button = document.getElementById('btn');
    button.onclick = function(){
      let username = document.getElementById('username').value;
      window.localStorage.setItem('username', username);
      window.location.href = 'userSearch.html';
    }

  });
</script>